$(document).ready(function() {
    jQuery("#grid").jqGrid({
        url:'/api/json/yachts',
        datatype: "json",
        colNames:['ID', 'Name', 'Owner', 'Purpose', 'Drive', 'Hull'],
        colModel:[
            {name:'yachtId',index:'yachtId', search:false},
            {name:'name',index:'name', search:true},
            {name:'ownerName',index:'ownerName', search:false, sortable:false},
            {name:'purpose',index:'purpose', search:true},
            {name:'drive',index:'drive', search:true},
            {name:'hull',index:'hull', search:true}
        ],
        autowidth: true,
        rowNum:15,
        onSelectRow: function(rowid) {
            var rowData = $("#grid").jqGrid('getRowData',rowid);
            window.open("/yacht/" + rowData.yachtId);
            window.focus();
        },
        height: "auto",
        pager: "#pagination",
        rowList:[15,20,30],
        sortname: 'yachtId',
        viewrecords: true,
        sortorder: "asc",
        rownumbers: true,
        jsonReader: {
            repeatitems : false,
            id: "0"
        }
    });
    jQuery("#grid").jqGrid('navGrid','#pagination',{edit:false,add:false,del:false,search:false,refresh:false});
    jQuery("#grid").jqGrid('filterToolbar', {
        searchOnEnter: false
    });
});